/**
 * 
 */
package menu.commands;

import java.awt.BorderLayout;
import java.awt.Container;
import javax.swing.*;
import util.commands.Command;
import view.Frame;
import view.panels.OptionList;

/**
 * Allows user to select the color, style, and visibility of the pen. Change the
 * shape of the turtle and change environment.
 * 
 * @author Josue Mirtil
 * 
 */
public class Option implements Command<Frame>
{
    private static final int PANEL_WIDTH = 600;
    private static final int PANEL_HEIGHT = 600;
    JFrame myFrame;
    JPanel myCanvas;

    @Override
    public void execute(Frame target)
    {
        // TODO: Use the already created PreferencesFrame

        myFrame = new JFrame();
        myFrame.setTitle("Option");
        myFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
        Container content = myFrame.getContentPane();
        OptionList option = new OptionList(target.getController());
        myCanvas = new JPanel();
        myCanvas.setSize(PANEL_WIDTH, PANEL_HEIGHT);
        content.add(option.getInstance(), BorderLayout.WEST);
        content.add(myCanvas, BorderLayout.CENTER);
        myFrame.setContentPane(content);
        myFrame.pack();
        myFrame.setVisible(true);

        // TODO: make the actual classes.
    }

    public void replacePane(JPanel newPanel)
    {
        myFrame.remove(myCanvas);
        myCanvas = newPanel;
        myCanvas.setSize(PANEL_WIDTH, PANEL_HEIGHT);
        Container content = myFrame.getContentPane();
        content.add(myCanvas, BorderLayout.CENTER);
        myFrame.setContentPane(content);
        myFrame.pack();
        myFrame.setVisible(true);
    }
}
